(function () {
    var nv = $("#nv"),//切换成男
        nan = $("#nan"),//切换成女
        input_nan = $("#nan input"),//男的input
        input_nv = $("#nv input"),//女的input
        exchange_sex = $(".exchange_sex"),//男女切换按钮
        xiaobiaoqian = $(".cus_interact i");
    exchange_sex.on("click", function () {
        if (nan.css("display") == "block") {
            nv.css("display", "block");
            nan.css("display", "none");
        } else {
            nv.css("display", "none");
            nan.css("display", "block");
        }
    })
    /*切换男女*/
    var select_size1 = $(".xingbie .select_size");
    $(".xingbie .select_size").each(function () {
        $(this).on("click", function () {
            select_size1.removeClass("active");
            $(this).addClass("active");
        })
    })
    /*切换尺寸*/
    var select_size = $(".chima .select_size");
    $(".chima .select_size").each(function () {
        $(this).on("click", function () {
            select_size.removeClass("active");
            $(this).addClass("active");
        })
    })
    /**加减数量**/
    var jianhao = $("#jianhao"),
        jiahao = $("#jiahao"),
        shuliang = $("#shuliang");
    // $(document).on("keyup",function (e) {
    //     var shuliang_val = parseInt(shuliang.val());
    //     var e = event || window.event || arguments.callee.caller.arguments[0];
    //     if(e && e.keyCode==8 && shuliang_val==""){
    //         $("span[data-true]").css("display","block");
    //     } else if(e && e.keyCode==48){
    //         $("span[data-true]").css("display","block");
    //     } else if(e.keyCode<48 ||e.keyCode>57){
    //         shuliang.val("1");
    //     }else {
    //         shuliang_val = e.keyCode - 48;
    //         shuliang.val(shuliang_val);
    //     }
    // })
    jianhao.on("click", function () {
        var shuliang_val = parseInt(shuliang.val());
        if (shuliang_val <= 1) {
            shuliang.val("1");
        }else if(shuliang.val()==""){
            $(document).on("click",function () {
                $("span[data-true]").css("display","block");
            })
        } else {
            shuliang_val = shuliang_val - 1;
            shuliang.val(shuliang_val);
        }
    })
    jiahao.on("click", function () {
        var shuliang_val = parseInt(shuliang.val());
        shuliang_val = shuliang_val + 1;
        shuliang.val(shuliang_val);
    })
    /**衣服下面的小标签点击变色**/
    // $(".cus_interact a").each(function () {
    //     $(this).on("click", function () {
    //         $(this).find(".iconfont").toggleClass("active");
    //     })
    // })
    /******点击重新选择***********/
    $("#chongxinxuanze").on("click", function () {
        location.href = "custom_detail.html";
    })


    /********底部的选项卡**********/
    $(".cus_option > ul > li").on("click", function () {
        var cur_index = $(this).index();
        $(this).addClass("active").siblings().removeClass("active");
        $(".cus_option_item .item").eq(cur_index).fadeIn().siblings().hide();
    })

    /**省市地区联动*/
    //省市 区三级联动
    $(function () {
        var pro = $("#pro"),
            city_name = $("#city"),
            direct_id = $("#direct"),
            xuanzechengshi = $("#xuanzechengshi");
        // xuanzediqu=$("#xuanzediqu");
        /*点击空白的时候加上请选择地区和选择城市*/
        var li_city = "<li>请选择城市</li>";
        city_name.append(li_city);
        // var li_direct="<li>请选择地区</li>";
        // direct_id.append(li_direct);
        $.each(province, function (k, p) {
            var li = "<li data-id='" + p.ProID + "'>" + p.ProName + "</li>";
            pro.append(li);
        });
        $("#pro li").on("click", function () {
            $("#city li").remove();
            $("#direct li").remove();
            /*清楚城市以及地区的值**/
            xuanzechengshi.val("");
            // xuanzediqu.val("");
            var pro_val = $(this).data("id");
            $.each(city, function (k, p) {
                if (p.ProID == pro_val) {
                    var li = "<li data-id='" + p.CityID + "'>" + p.CityName + "</li>";
                    city_name.append(li);
                }
            });
        });
    });

    /**点击小图，改变大图的位置****/
    $(".xiaotu ul li a").on("click", function () {
        var that = this;
        var zoomsrc=$(this).children()[0].src;
        $(".xiaotu ul li a").removeClass("active");
        $(this).addClass("active");
        // $(".cus_img>img").attr("src", src);
        // var src=zoomsrc.replace("http://localhost:63342/Project-BuErShop/src/","../../");
        // $("#fangdatu>img")[0].setAttribute("data-cloudzoom","zoomImage: '"+src+"'");
    })

    //点击分享图标，显示qq
    $(".fenxiang").on("click",function(){
        console.log($(".cus_interact img").parent());
        $(".cus_interact img").parent().toggleClass("show_detail");
    });
    $(".shoucang").on("click",function () {
        $(this).find("i").toggleClass("active");
    });






})();
